package com.shangye.core;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 项目启动类
 */
public class ShangYeApplication {

    private ServerSocket serverSocket;

    public ShangYeApplication(){

        try {
            System.out.println("服务器启动中...");
            serverSocket = new ServerSocket(8088);
            System.out.println("服务器已启动！");
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public void start(){
        try {
            System.out.println("正在等待客户连接...");
            Socket socket = serverSocket.accept();
            System.out.println("一个客户已连接上服务器!");

            ClientHandler handler = new ClientHandler(socket);
            new Thread(handler).start();

        } catch (IOException e) {
            e.printStackTrace();
        }


    }
    // 主方法
    public static void main(String[] args) {

        new ShangYeApplication().start();

    }



}
